<?php

namespace app\admin\model;

class Admin extends \think\Model
{
    protected $readonly = ['username'];

    protected $name = 'admin';

    public static function onBeforeDelete($model)
    {
        if ($model['id'] == 1 || $model['username'] == 'admin') {
            throw new \Exception('超级管理员无法删除');
        }
    }

    public function group()
    {
        return $this->belongsTo(Group::class, 'group_id', 'id');
    }

    public function getLogintimeAttr($v){
        return $v?date('Y-m-d H:i:s',$v):'';
    }
}
